home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / grafica / pvrgjpeg / lexer.c < prev    next >
C/C++ Source or Header  |  1999-01-01  |  42KB  |  1,988 lines

  1. /*************************************************************
  2. Copyright (C) 1990, 1991, 1993 Andy C. Hung, all rights reserved.
  3. PUBLIC DOMAIN LICENSE: Stanford University Portable Video Research
  4. Group. If you use this software, you agree to the following: This
  5. program package is purely experimental, and is licensed "as is".
  6. Permission is granted to use, modify, and distribute this program
  7. without charge for any purpose, provided this license/ disclaimer
  8. notice appears in the copies.  No warranty or maintenance is given,
  9. either expressed or implied.  In no event shall the author(s) be
  10. liable to you or a third party for any special, incidental,
  11. consequential, or other damages, arising out of the use or inability
  12. to use the program for any purpose (or the loss of data), even if we
  13. have been advised of such possibilities.  Any public reference or
  14. advertisement of this source code should refer to it as the Portable
  15. Video Research Group (PVRG) code, and not by any author(s) (or
  16. Stanford University) name.
  17. *************************************************************/
  18. # include "stdio.h"
  19. # define U(x) ((x)&0377)
  20. # define NLSTATE yyprevious=YYNEWLINE
  21. # define BEGIN yybgin = yysvec + 1 +
  22. # define INITIAL 0
  23. # define YYLERR yysvec
  24. # define YYSTATE (yyestate-yysvec-1)
  25. # define YYOPTIM 1
  26. # define YYLMAX 200
  27. # define output(c) putc(c,yyout)
  28. # define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)
  29. # define unput(c) {yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;}
  30. # define yymore() (yymorfg=1)
  31. # define ECHO fprintf(yyout, "%s",yytext)
  32. # define REJECT { nstr = yyreject(); goto yyfussy;}
  33. int yyleng; extern char yytext[];
  34. int yymorfg;
  35. extern char *yysptr, yysbuf[];
  36. int yytchar;
  37. FILE *yyin ={stdin}, *yyout ={stdout};
  38. extern int yylineno;
  39. struct yysvf { 
  40.     struct yywork *yystoff;
  41.     struct yysvf *yyother;
  42.     int *yystops;};
  43. struct yysvf *yyestate;
  44. extern struct yysvf yysvec[], *yybgin;
  45.  
  46. /*LABEL lexer.c */
  47.  
  48. /* Redefine the yywrap so that we don't have
  49.    to worry about lex library */
  50.  
  51. # define yywrap() (1)
  52.  
  53. static char *ReservedWords[] = {   /* Token names */
  54. "COMPONENT",
  55. "SCAN",
  56. "QUANTIZATION",
  57. "DCSPEC",
  58. "ACCUSTOM",
  59. "DCCUSTOM",
  60. "PRINTSCAN",
  61. "PRINTFRAME",
  62. "PRINTIMAGE",
  63. "OPENSCAN",
  64. "ACSPEC",
  65. "WRITESCAN",
  66. "WRITEFRAME",
  67. "WRITESOI",
  68. "WRITEQUANTIZATION",
  69. "WRITERESYNC",
  70. "WRITEHUFFMAN",
  71. "FREQUENCY",
  72. "ACSEND",
  73. "DCSEND",
  74. "QSEND",
  75. "STREAMNAME",
  76. "IMAGEHEIGHT",
  77. "IMAGEWIDTH",
  78. "RESYNC",
  79. "BUFFER",
  80. "OPENSTREAM",
  81. "CLOSESTREAM",
  82. "FRAMEHEIGHT",
  83. "FRAMEWIDTH",
  84. "CLOSESCAN",
  85. "WRITEEOI",
  86. "ECHO",
  87. "WRITESPECIAL",
  88. "WRITEDIRECT",
  89. "LUMINANCEDEFAULT",
  90. "CHROMINANCEDEFAULT",
  91. "ENABLE",
  92. "SCANDNL",
  93. "WRITEDNL",
  94. "AUTO",
  95. "EMPTY",
  96. ""};
  97.  
  98. #define R_COMPONENT 1           /* Token values mapped to token names */
  99. #define R_SCAN 2
  100. #define R_QUANTIZATION 3
  101. #define R_DCSPEC 4
  102. #define R_ACCUSTOM 5
  103. #define R_DCCUSTOM 6
  104. #define R_PRINTSCAN 7
  105. #define R_PRINTFRAME 8
  106. #define R_PRINTIMAGE 9
  107. #define R_OPENSCAN 10
  108. #define R_ACSPEC 11
  109. #define R_WRITESCAN 12
  110. #define R_WRITEFRAME 13
  111. #define R_WRITESOI 14
  112. #define R_WRITEQUANTIZATION 15
  113. #define R_WRITERESYNC 16
  114. #define R_WRITEHUFFMAN 17
  115. #define R_FREQUENCY 18
  116. #define R_ACSEND 19
  117. #define R_DCSEND 20
  118. #define R_QSEND 21
  119. #define R_STREAMNAME 22
  120. #define R_IMAGEHEIGHT 23
  121. #define R_IMAGEWIDTH 24
  122. #define R_RESYNC 25
  123. #define R_BUFFER 26
  124. #define R_OPENSTREAM 27
  125. #define R_CLOSESTREAM 28
  126. #define R_FRAMEHEIGHT 29
  127. #define R_FRAMEWIDTH 30
  128. #define R_CLOSESCAN 31
  129. #define R_WRITEEOI 32
  130. #define R_ECHO 33
  131. #define R_WRITESPECIAL 34
  132. #define R_WRITEDIRECT 35
  133. #define R_LUMINANCEDEFAULT 36
  134. #define R_CHROMINANCEDEFAULT 37
  135. #define R_ENABLE 38
  136. #define R_SCANDNL 39
  137. #define R_WRITEDNL 40
  138. #define R_AUTO 41
  139. #define R_EMPTY 42
  140.  
  141. #define R_INTEGER 1000      /* Special TYPES for tokens */
  142. #define R_LBRACKET 1001
  143. #define R_RBRACKET 1002
  144. #define R_ID 1003
  145. #define R_STRING 1004
  146.  
  147. int CommentDepth = 0;  /* depth of comment nesting */
  148. int yyint=0;           /* Return value for integers */
  149. int LexDebug=0;        /* Status of lex debugging */
  150.  
  151. #define PRIME 211
  152. #define EOS '\0'
  153.  
  154. #define MakeStructure(S) (S *) malloc(sizeof(S))
  155. #define InsertLink(link,list){\
  156. if(!list){list=link;}else{link->next=list;list=link;}}
  157.  
  158. #define LINK struct link_def
  159. struct id {         /* Default id structure */
  160.   char *name;       /* Key */
  161.   int tokentype;    /* Token type */
  162.   int count;        /* Count of # references */
  163. };
  164.  
  165. LINK {              /* A link for the hash buckets */
  166. struct id *lid;     /* Current id */
  167. LINK *next;         /* Pointer to next id */
  168. };
  169.  
  170. /*PUBLIC*/
  171.  
  172. extern void initparser();
  173. extern void parser();
  174.  
  175. static int hashpjw();
  176. static LINK * MakeLink();
  177. static struct id * enter();
  178. static int getint();
  179. static char * getstr();
  180.  
  181. /*PRIVATE*/
  182.  
  183. /*NOPROTO*/
  184.  
  185. # define NORMAL 2
  186. # define COMMENT 4
  187. # define YYNEWLINE 10
  188. yylex(){
  189. int nstr; extern int yyprevious;
  190. while((nstr = yylook()) >= 0)
  191. yyfussy: switch(nstr){
  192. case 0:
  193. if(yywrap()) return(0); break;
  194. case 1:
  195. {}
  196. break;
  197. case 2:
  198. {struct id *temp; temp = enter(0,yytext,yyleng); 
  199.          if (LexDebug)
  200.            {
  201.              printf("%s : %s (%d)\n",
  202.                 yytext,
  203.                 ((temp->tokentype) ? "RESERVED" : "IDENTIFIER"),
  204.                 temp->count);
  205.            }
  206.          if (temp->tokentype)
  207.            {
  208.              return(temp->tokentype);
  209.            }
  210.          else
  211.            {
  212.              return(R_ID);
  213.            }
  214.            }
  215. break;
  216. case 3:
  217.         {if (LexDebug)
  218.                {
  219.                  printf("%s : %s\n", yytext, "REAL");
  220.                }
  221.                }
  222. break;
  223. case 4:
  224. {if (LexDebug)
  225.                {             
  226.                  printf("%s : %s\n", yytext, "INTEGER");
  227.                }
  228.              yyint = atoi(yytext);
  229.              return(R_INTEGER);}
  230. break;
  231. case 5:
  232. {if (LexDebug)
  233.                {
  234.                  printf("%s : %s\n", yytext, "(HEX)INTEGER");
  235.                }
  236.              yyint = strtol(yytext+2,NULL,16);
  237.              return(R_INTEGER);}
  238. break;
  239. case 6:
  240. {if (LexDebug)
  241.                {
  242.                  printf("%s : %s\n", yytext, "(HEX)INTEGER");
  243.                }
  244.              yyint = strtol(yytext,NULL,16);
  245.              return(R_INTEGER);}
  246. break;
  247. case 7:
  248. {if (LexDebug)
  249.                {
  250.                  printf("%s : %s\n", yytext, "(OCT)INTEGER");
  251.                }
  252.              yyint = strtol(yytext+2,NULL,8);
  253.              return(R_INTEGER);}
  254. break;
  255. case 8:
  256. {if (LexDebug)
  257.                {
  258.                  printf("%s : %s\n", yytext, "(OCT)INTEGER");
  259.                }
  260.              yyint = strtol(yytext,NULL,8);
  261.              return(R_INTEGER);}
  262. break;
  263. case 9:
  264. {if (LexDebug)
  265.                {
  266.                  printf("%s : %s\n", yytext, "(CHAR)INTEGER");
  267.                }
  268.              if (yyleng>4)
  269.                {
  270.                  yyint = strtol(yytext+2,NULL,8);
  271.                }
  272.              else
  273.                {
  274.                  if (*(yytext+1)=='\\')
  275.                    {
  276.                  switch(*(yytext+2))
  277.                    {
  278.                    case '0':
  279.                      yyint=0;
  280.                      break;
  281.                    case 'b':
  282.                      yyint = 0x8;
  283.                      break;
  284.                    case 'i':
  285.                      yyint = 0x9;
  286.                      break;
  287.                    case 'n':
  288.                      yyint = 0xa;
  289.                      break;
  290.                    case 'v':
  291.                      yyint = 0xb;
  292.                      break;
  293.                    case 'f':
  294.                      yyint = 0xc;
  295.                      break;
  296.                    case 'r':
  297.                      yyint = 0xd;
  298.                      break;
  299.                    default:
  300.                      yyint=(*yytext+2);
  301.                      break;
  302.                    }
  303.                    }
  304.                  else
  305.                    {
  306.                  yyint = *(yytext+1);
  307.                    }
  308.                }
  309.              return(R_INTEGER);}
  310. break;
  311. case 10:
  312.         {if (LexDebug)
  313.                {
  314.                  printf("%s : %s\n", yytext, "LBRACKET");
  315.                }
  316.              return(R_LBRACKET);}
  317. break;
  318. case 11:
  319.         {if (LexDebug)
  320.                {
  321.                  printf("%s : %s\n", yytext, "RBRACKET");
  322.                }
  323.              return(R_RBRACKET);}
  324. break;
  325. case 12:
  326. {if (LexDebug)
  327.                {
  328.                  printf("%s : %s\n", yytext, "OPERATOR");
  329.                }
  330.                }
  331. break;
  332. case 13:
  333. {if (LexDebug)
  334.                {
  335.                  printf("%s : %s\n", yytext, "STRING");
  336.                }
  337.              return(R_STRING);}
  338. break;
  339. case 14:
  340. {CommentDepth++; BEGIN COMMENT;}
  341. break;
  342. case 15:
  343.     {CommentDepth--;if(!CommentDepth) BEGIN NORMAL;}
  344. break;
  345. case 16:
  346.             {
  347.                   /* None of the above rules applicable, so
  348.                    it's a bad symbol. */
  349.                               printf("Bad input char '%c' on line %d\n",
  350.                             yytext[0],
  351.                             yylineno);
  352.                   }
  353. break;
  354. case 17:
  355.     {}
  356. break;
  357. case -1:
  358. break;
  359. default:
  360. fprintf(yyout,"bad switch yylook %d",nstr);
  361. } return(0); }
  362. /* end of yylex */
  363.  
  364. /*PROTO*/
  365. LINK *HashTable[PRIME];  /* My little hash table */
  366.  
  367. /*START*/
  368.  
  369. /*BFUNC
  370.  
  371. initparser() is used to place the Reserved Words into the hash table.
  372. It must be called before the parser command is called.
  373.  
  374. EFUNC*/
  375.  
  376. void initparser()
  377. {
  378.   char i,**sptr;
  379.   BEGIN NORMAL;
  380.  
  381.   for(i=1,sptr=ReservedWords;**sptr!='\0';i++,sptr++) 
  382.     {     /* Add Reserved Words */
  383.       enter(i,*sptr,strlen(*sptr));        /* Put reserved words in */
  384.     }                                      /* hash table */
  385. }
  386.  
  387. #undef BEGIN
  388. #undef MakeStructure
  389. #include "globals.h"
  390. #include "stream.h"
  391. #include "tables.h"
  392.  
  393. extern FRAME *CFrame;
  394. extern IMAGE *CImage;
  395. extern SCAN *CScan;
  396. extern int ErrorValue;
  397.  
  398. /*BFUNC
  399.  
  400. hashpjw() returns a hash value for a string input.
  401.  
  402. EFUNC*/
  403.  
  404. static int hashpjw(s)
  405.      char *s;
  406. {
  407.   BEGIN("hashpjw");
  408.   char *p;
  409.   unsigned int h=0,g;
  410.  
  411.   for(p=s;*p!=EOS;p++)       /* Taken from Aho Sethi Ullman Compilers book. */
  412.     {
  413.       h = (h << 4) + *p;
  414.       if (g = h&0xf0000000)
  415.     {
  416.       h = h ^(g >> 24);
  417.       h = h ^ g;
  418.     }
  419.     }
  420.   return(h % PRIME);
  421. }
  422.  
  423. /*BFUNC
  424.  
  425. MakeLink() is used to construct a link object. The link
  426. is used for the hash table construct.
  427.  
  428. EFUNC*/
  429.  
  430.  
  431. static LINK *MakeLink(tokentype,str,len)
  432.      int tokentype;
  433.      char *str;
  434.      int len;
  435. {
  436.   BEGIN("MakeLink");
  437.   LINK *temp;
  438.   
  439.   if (!(temp = MakeStructure(LINK)))            /* Make link */
  440.     {
  441.       WHEREAMI();
  442.       printf("Cannot make a LINK.\n");
  443.       exit(ERROR_MEMORY);
  444.     }
  445.   if (!(temp->lid = MakeStructure(struct id)))  /* Make id */
  446.     {
  447.       printf("Cannot make an id.\n");
  448.       exit(ERROR_MEMORY);
  449.     }
  450.   temp->next = NULL;                            /* Set fields */
  451.   if (!(temp->lid->name =(char *)calloc(len+1,sizeof(char))))
  452.     {
  453.       printf("Cannot make a string space for the link.\n");
  454.       exit(ERROR_MEMORY);
  455.     }
  456.   strcpy(temp->lid->name,str);                 /* Copy key */
  457.   temp->lid->tokentype = tokentype;
  458.   temp->lid->count = 1; 
  459.   return(temp);
  460. }
  461.  
  462. /*BFUNC
  463.  
  464. enter() is used to enter a Reserved Word or ID into the hash table.
  465.  
  466. EFUNC*/
  467.  
  468. static struct id *enter(tokentype,str,len)
  469.      int tokentype;
  470.      char *str;
  471.      int len;
  472. {
  473.   BEGIN("enter");
  474.   int hashnum;
  475.   LINK *temp,*current;
  476.   char *ptr;
  477.  
  478.   for(ptr=str;*ptr!='\0';ptr++)          /* All capitals is fine */
  479.     {
  480.       if ((*ptr>='a') && (*ptr<='z'))
  481.     {
  482.       *ptr = *ptr - ('a'-'A');
  483.     }
  484.     }
  485.   hashnum = hashpjw(str);                /* Check if in hash table */
  486.   for(temp=NULL,current=HashTable[hashnum];
  487.       current!= NULL;
  488.       current=current->next)
  489.     {
  490.       if (strcmp(str,current->lid->name) == 0)
  491.     {
  492.       temp=current;
  493.       break;
  494.     }
  495.     }
  496.   if (temp)                          /* Yes, found ID then return */
  497.     {
  498.       temp->lid->count++;
  499.       return(temp->lid);
  500.     }
  501.   else                              /* Else make our own ID and return that*/
  502.     {
  503.       temp = MakeLink(tokentype,str,len);
  504.       InsertLink(temp,HashTable[hashnum]);
  505.       return(temp->lid);
  506.     }
  507. }
  508.  
  509. /*BFUNC
  510.  
  511. getint() takes an integer from the input.
  512.  
  513. EFUNC*/
  514.  
  515. static int getint()
  516. {
  517.   BEGIN("getint");
  518.   int type;
  519.   if ((type=yylex())!=R_INTEGER)
  520.     {
  521.       printf("Bad input, not integer, '%s' on line %d\n",
  522.          yytext,
  523.          yylineno);
  524.       return(0);
  525.     }
  526.   return(yyint);
  527. }
  528.  
  529. /*BFUNC
  530.  
  531. getstr() gets a string from the input. It copies the string to
  532. temporary storage before it returns the pointer.
  533.  
  534. EFUNC*/
  535.  
  536. static char *getstr()
  537. {
  538.   BEGIN("getstr");
  539.   char *tmp,*ptr,*bptr;
  540.   int i,accum,flag;
  541.   if (yylex() != R_STRING)                      /* Check if string */
  542.     {
  543.       printf("String expected.\n");
  544.       if (!(tmp=(char *) malloc(sizeof(char))))
  545.     {
  546.       WHEREAMI();
  547.       printf("Cannot allocate for null string.\n");
  548.       exit(ERROR_MEMORY);
  549.     }
  550.       *tmp='\0';
  551.       return(tmp);
  552.     }
  553.   if (!(tmp=(char *)calloc(strlen(yytext)+1,sizeof(char)))) /* Make space */
  554.     {
  555.       WHEREAMI();
  556.       printf("Cannot allocate %d string space.\n",yyleng);
  557.       exit(ERROR_MEMORY);
  558.     }
  559.   for(bptr=yytext+1,ptr=tmp;*bptr!='"';bptr++,ptr++)   /* Copy to string */
  560.     {
  561.       if (*bptr=='\\')
  562.     {
  563.       bptr++;
  564.       for(flag=0,accum=0,i=0;i<3;i++)  /* Octal character lookahead */
  565.         {
  566.           if ((*bptr>='0')&&(*bptr<='7'))
  567.         {
  568.           accum = (accum<<3)+(*bptr-'0');
  569.           bptr++;
  570.           flag=1;
  571.         }
  572.           else
  573.         {
  574.           break;
  575.         }
  576.         }
  577.       if (flag)
  578.         {
  579.           bptr--;
  580.           *ptr=accum;
  581.         }
  582.       else                           /* Do conversions, if necessary */
  583.         {
  584.           switch(*(bptr))
  585.         {
  586.         case '0':
  587.           *ptr = 0;
  588.           break;
  589.         case 'b':
  590.           *ptr = 0x8;
  591.           break;
  592.         case 'i':
  593.           *ptr = 0x9;
  594.           break;
  595.         case 'n':
  596.           *ptr = 0xa;
  597.           break;
  598.         case 'v':
  599.           *ptr = 0xb;
  600.           break;
  601.         case 'f':
  602.           *ptr = 0xc;
  603.           break;
  604.         case 'r':
  605.           *ptr = 0xd;
  606.           break;
  607.         default:
  608.           *ptr=(*bptr);
  609.         }
  610.         }
  611.     }
  612.       else
  613.     {
  614.       *ptr = (*bptr);
  615.     }
  616.     }
  617.   *ptr='\0';
  618.   return(tmp);
  619. }
  620.  
  621. /*BFUNC
  622.  
  623. parser() handles all of the parsing required for the Command
  624. Interpreter.  It is basically a while statement with a very large case
  625. statement for every input. The Command Interpreter is essentially
  626. driven by the keywords. All unmatched values such as integers,
  627. strings, and brackets, are ignored.
  628.  
  629. EFUNC*/
  630.  
  631. #define ARRAYBEGIN if (ntoken==R_LBRACKET)\
  632.         {\
  633.           arrayflag=1;\
  634.           ntoken=yylex();\
  635.         }\
  636.       if (ntoken!=R_INTEGER)\
  637.         {\
  638.           WHEREAMI();\
  639.           printf("Expected integer.\n");\
  640.           break;\
  641.         }\
  642.       while(1)\
  643.         {
  644.  
  645. #define ARRAYEND  if (arrayflag)\
  646.         {\
  647.           if ((ntoken=yylex())==R_RBRACKET) break;\
  648.           else if (ntoken!=R_INTEGER)\
  649.             {\
  650.               WHEREAMI();\
  651.               printf("Expected integer or right bracket.\n");\
  652.               break;\
  653.             }\
  654.         }\
  655.           else break;\
  656.           }
  657.  
  658. void parser()
  659. {
  660.   BEGIN("parser");
  661.   int i,dest,value,token,ntoken,arrayflag;
  662.   int accum;
  663.   int Start,End;
  664.   int *ptr,*ptr2;
  665.  
  666.   while(token=yylex())        /* The code handling is simple enough. */
  667.     {                         /* just read the code and documentation */
  668.       ErrorValue=0;           /* book... */
  669.       arrayflag=0;
  670.       switch(token)
  671.     {
  672.     case R_ECHO:
  673.       printf("%s\n",getstr());
  674.       break;
  675.     case R_PRINTIMAGE:
  676.       PrintImage();
  677.       break;
  678.     case R_PRINTFRAME:
  679.       PrintFrame();
  680.       break;
  681.     case R_PRINTSCAN:
  682.       PrintScan();
  683.       break;
  684.     case R_COMPONENT:
  685.       ntoken=yylex();
  686.       ARRAYBEGIN;
  687.       dest = yyint;
  688.       InBounds(dest,0,MAXIMUM_COMPONENTS-1,"Bad component reference");
  689.       if (ErrorValue) break;
  690.       if (yylex()!=R_LBRACKET)
  691.         {
  692.           WHEREAMI();
  693.           printf("Expected left bracket.\n");
  694.           break;
  695.         }
  696.       CFrame->ComponentFileName[dest] = getstr();
  697.       value=getint();
  698.       InBounds(value,0,MAXIMUM_HORIZONTAL_FREQUENCY,
  699.            "Bad horizontal frequency");
  700.       if (ErrorValue) break;
  701.       CFrame->hf[dest]=value;
  702.       value=getint();
  703.       InBounds(value,0,MAXIMUM_VERTICAL_FREQUENCY,
  704.            "Bad vertical frequency");
  705.       if (ErrorValue) break;
  706.       CFrame->vf[dest]=value;
  707.       value=getint();
  708.       InBounds(value,0,MAXIMUM_DEVICES-1,"Bad device reference");
  709.       if (ErrorValue) break;
  710.       CFrame->tq[dest]=value;
  711.       CFrame->cn[CFrame->GlobalNumberComponents++]=dest;/*Know to use it*/
  712.       if (yylex()!=R_RBRACKET)
  713.         {
  714.           WHEREAMI();
  715.           printf("Expected right bracket.\n");
  716.           break;
  717.         }
  718.       ARRAYEND;
  719.       break;
  720.     case R_SCAN:
  721.       CScan->NumberComponents=0;
  722.       ntoken=yylex();
  723.       ARRAYBEGIN;
  724.       if (CScan->NumberComponents>=MAXIMUM_SOURCES)
  725.         {
  726.           WHEREAMI();
  727.           printf("Exceeded number of sources per scan.\n");
  728.           break;
  729.         }
  730.       InBounds(yyint,0,MAXIMUM_COMPONENTS-1,"Bad component reference");
  731.       if (ErrorValue) break;
  732.       for(i=0;i<CFrame->GlobalNumberComponents;i++)  /* Check there */
  733.             if (CFrame->cn[i]==yyint) break;
  734.       if (i==CFrame->GlobalNumberComponents)
  735.         {
  736.           WHEREAMI();
  737.           printf("Scan index not defined in frame yet.\n");
  738.           break;
  739.         }
  740.       CScan->ci[CScan->NumberComponents] = yyint;
  741.       if (yylex()!=R_LBRACKET)
  742.         {
  743.           WHEREAMI();
  744.           printf("Expected left bracket.\n");
  745.           break;
  746.         }
  747.       value=getint();
  748.       InBounds(value,0,MAXIMUM_DEVICES-1,"Bad device reference");
  749.       if (ErrorValue) break;
  750.       CScan->td[CScan->NumberComponents]=value;
  751.       value=getint();
  752.       InBounds(value,0,MAXIMUM_DEVICES-1,"Bad device reference");
  753.       if (ErrorValue) break;
  754.       CScan->ta[CScan->NumberComponents]=value;
  755.       CScan->NumberComponents++;
  756.       if (yylex()!=R_RBRACKET)
  757.         {
  758.           WHEREAMI();
  759.           printf("Expected right bracket.\n");
  760.           break;
  761.         }
  762.       ARRAYEND;
  763.       break;
  764.     case R_QUANTIZATION:
  765.       ntoken=yylex();
  766.       ARRAYBEGIN;
  767.       dest = yyint;
  768.       InBounds(dest,0,MAXIMUM_DEVICES-1,
  769.            "Bad quantization reference.");
  770.       if (ErrorValue) break;
  771.       ntoken=yylex();
  772.       if (ntoken==R_LUMINANCEDEFAULT)
  773.         {
  774.           CImage->QuantizationMatrices[dest]=LuminanceQuantization;
  775.           break;
  776.         }
  777.       else if (ntoken==R_CHROMINANCEDEFAULT)
  778.         {
  779.           CImage->QuantizationMatrices[dest]=ChrominanceQuantization;
  780.           break;
  781.         }
  782.       else if (ntoken!=R_LBRACKET)
  783.         {
  784.           WHEREAMI();
  785.           printf("Expected left bracket.\n");
  786.           break;
  787.         }
  788.       CImage->NumberQuantizationMatrices =
  789.         MAX(CImage->NumberQuantizationMatrices,(dest+1));
  790.       if (!(ptr=(int *)calloc(64,sizeof(int))))
  791.         {
  792.           WHEREAMI();
  793.           printf("Cannot allocate quantization matrix.\n");
  794.           exit(ERROR_MEMORY);
  795.         }
  796.       CImage->NumberQuantizationMatrices =
  797.         MAX(CImage->NumberQuantizationMatrices,(dest+1));
  798.       CImage->QuantizationMatrices[dest]=ptr;
  799.       for(i=0;i<64;i++)
  800.         {
  801.           ptr[i]=16;
  802.         }
  803.       for(i=0;i<65;i++,ptr++) /* One additional to force r-bracket */
  804.         {
  805.           if ((ntoken=yylex())!=R_INTEGER) break;
  806.           InBounds(yyint,1,65535,"Integer out of bounds");
  807.           if (ErrorValue) yyint=16;
  808.           *ptr = yyint;
  809.         }
  810.       if (ntoken!=R_RBRACKET)
  811.         {
  812.           WHEREAMI();
  813.           printf("Expected integer or right bracket.\n");
  814.           break;
  815.         }
  816.       ARRAYEND;
  817.       break;
  818.     case R_ACSEND:
  819.       ntoken=yylex();
  820.       if (ntoken==R_EMPTY)
  821.         {
  822.           CScan->NumberACTablesSend = 0;
  823.           break;
  824.         }
  825.       ARRAYBEGIN;
  826.       if (CScan->NumberACTablesSend>=MAXIMUM_DEVICES)
  827.         {
  828.           WHEREAMI();
  829.           printf("AC Huffman queue full.\n");
  830.           break;
  831.         }
  832.       InBounds(yyint,0,MAXIMUM_DEVICES-1,"Bad device reference");
  833.       if (ErrorValue) break;
  834.       CScan->sa[CScan->NumberACTablesSend++] = yyint;
  835.       ARRAYEND;
  836.       break;
  837.     case R_DCSEND:
  838.       ntoken=yylex();
  839.       if (ntoken==R_EMPTY)
  840.         {
  841.           CScan->NumberDCTablesSend = 0;
  842.           break;
  843.         }
  844.       ARRAYBEGIN;
  845.       if (CScan->NumberDCTablesSend>=MAXIMUM_DEVICES)
  846.         {
  847.           WHEREAMI();
  848.           printf("DC Huffman queue full.\n");
  849.           break;
  850.         }
  851.       InBounds(yyint,0,MAXIMUM_DEVICES-1,"Bad device reference");
  852.       if (ErrorValue) break;
  853.       CScan->sd[CScan->NumberDCTablesSend++] = yyint;
  854.       ARRAYEND;
  855.       break;
  856.     case R_QSEND:
  857.       ntoken=yylex();
  858.       if (ntoken==R_EMPTY)
  859.         {
  860.           CScan->NumberQTablesSend = 0;
  861.           break;
  862.         }
  863.       ARRAYBEGIN;
  864.       if (CScan->NumberQTablesSend>=MAXIMUM_DEVICES)
  865.         {
  866.           WHEREAMI();
  867.           printf("Quantization queue full.\n");
  868.           break;
  869.         }
  870.       InBounds(yyint,0,MAXIMUM_DEVICES-1,"Bad device reference");
  871.       if (ErrorValue) break;
  872.       CScan->sq[CScan->NumberQTablesSend++] = yyint;
  873.       ARRAYEND;
  874.       break;
  875.     case R_STREAMNAME:
  876.       CImage->StreamFileName = getstr();
  877.       break;
  878.     case R_IMAGEWIDTH:
  879.       value=getint();
  880.       InBounds(value,0,MAXIMUM_IMAGE_WIDTH,"Bad image width");
  881.       CFrame->GlobalWidth = value;
  882.       break;
  883.     case R_IMAGEHEIGHT:
  884.       value=getint();
  885.       InBounds(value,0,MAXIMUM_IMAGE_HEIGHT,"Bad image height");
  886.       CFrame->GlobalHeight = value;
  887.       break;
  888.     case R_SCANDNL:
  889.       ntoken=yylex();
  890.       switch(ntoken)
  891.         {
  892.         case R_AUTO:
  893.           CFrame->InsertDnl= -2;
  894.           break;
  895.         case R_ENABLE:
  896.           CFrame->InsertDnl= -1;
  897.           break;
  898.         case R_INTEGER:
  899.           CFrame->InsertDnl = yyint;
  900.           break;
  901.         default:
  902.           WHEREAMI();
  903.           printf("Expected integer.\n");
  904.           break;
  905.         }
  906.       break;
  907.     case R_FRAMEWIDTH:
  908.       ntoken=yylex();
  909.       ARRAYBEGIN;
  910.       dest = yyint;
  911.       InBounds(dest,0,MAXIMUM_COMPONENTS-1,"Bad component destination");
  912.       if (ErrorValue) break;
  913.       value=getint();
  914.       InBounds(value,0,MAXIMUM_IMAGE_WIDTH,"Bad frame width");
  915.       if (ErrorValue) break;
  916.       CFrame->Width[dest] = value;
  917.       ARRAYEND;
  918.       break;
  919.     case R_FRAMEHEIGHT:
  920.       ntoken=yylex();
  921.       ARRAYBEGIN;
  922.       dest = yyint;
  923.       InBounds(dest,0,MAXIMUM_COMPONENTS-1,"Bad component destination");
  924.       if (ErrorValue) break;
  925.       value=getint();
  926.       InBounds(value,0,MAXIMUM_IMAGE_HEIGHT,"Bad frame height");
  927.       if (ErrorValue) break;
  928.       CFrame->Height[dest] = value;
  929.       ARRAYEND;
  930.       break;
  931.     case R_RESYNC:
  932.       value = getint();
  933.       InBounds(value,0,MAXIMUM_RESYNC_INTERVAL,"Bad resync interval");
  934.       if (ErrorValue) break;
  935.       CFrame->ResyncInterval = value;
  936.       break;
  937.     case R_BUFFER:
  938.       value = getint();
  939.       InBounds(value,MINIMUM_BUFFERSIZE,
  940.            MAXIMUM_BUFFERSIZE,"Bad buffersize");
  941.       if (ErrorValue) break;
  942.       CFrame->BufferSize = value;
  943.       break;
  944.     case R_OPENSCAN:
  945.       CheckValidity();
  946.       CheckBaseline();
  947.       ConfirmFileSize();
  948.       MakeIob(IOB_BLOCK,O_RDONLY,1);
  949.       break;
  950.     case R_CLOSESCAN:
  951.       for(i=0;i<CScan->NumberComponents;i++)  /* Close all components */
  952.         {
  953.           InstallIob(i);
  954.           CloseIob();
  955.         }
  956.       break;
  957.     case R_OPENSTREAM:
  958.       if (CImage->StreamFileName)
  959.         {
  960.           swopen(CImage->StreamFileName,0);  /* Index 0 open */
  961.         }
  962.       else
  963.         {
  964.           printf("StreamFileName: Null. Failed\n");
  965.         }
  966.       break;
  967.     case R_CLOSESTREAM:
  968.       swclose();
  969.       break;
  970.     case R_FREQUENCY:
  971.       JpegFrequencyScan();
  972.       break;
  973.     case R_WRITESPECIAL:
  974.       ntoken=yylex();
  975.       ARRAYBEGIN;
  976.       value = yyint;
  977.       swbytealign();
  978.       bputc(0xFF);  /* Marker */
  979.       bputc(value&0xff);
  980.       Start = swtell();
  981.       bputw(0);
  982.       if (yylex()!=R_LBRACKET)
  983.         {
  984.           WHEREAMI();
  985.           printf("Expected left bracket.\n");
  986.           End = swtell();
  987.           swseek(Start);
  988.           bputw((End-Start) >> 3);
  989.           swseek(End);
  990.           break;
  991.         }
  992.       while((ntoken=yylex())==R_INTEGER)
  993.         {
  994.           bputc(yyint&0xff);
  995.         }
  996.       if (ntoken!=R_RBRACKET)
  997.         {
  998.           WHEREAMI();
  999.           printf("Expected integer or right bracket.\n");
  1000.           End = swtell();
  1001.           swseek(Start);
  1002.           bputw((End-Start) >> 3);
  1003.           swseek(End);
  1004.           break;
  1005.         }
  1006.       End = swtell();
  1007.       swseek(Start);
  1008.       bputw((End-Start) >> 3);
  1009.       swseek(End);
  1010.       ARRAYEND;
  1011.       break;
  1012.     case R_WRITEDIRECT:
  1013.       swbytealign();
  1014.       if (yylex()!=R_LBRACKET)
  1015.         {
  1016.           WHEREAMI();
  1017.           printf("Expected left bracket.\n");
  1018.           break;
  1019.         }
  1020.       while((ntoken=yylex())==R_INTEGER)
  1021.         {
  1022.           bputc(yyint&0xff);
  1023.         }
  1024.       if (ntoken!=R_RBRACKET)
  1025.         {
  1026.           WHEREAMI();
  1027.           printf("Expected integer or right bracket.\n");
  1028.           break;
  1029.         }
  1030.       break;
  1031.     case R_WRITESCAN:
  1032.       JpegEncodeScan();
  1033.       break;
  1034.     case R_WRITEFRAME:
  1035.       MakeConsistentFrameSize();  /* Do it here when everything defined */
  1036.       WriteSof();
  1037.       break;
  1038.     case R_WRITESOI:
  1039.       WriteSoi();
  1040.       break;
  1041.     case R_WRITEEOI:
  1042.       WriteEoi();
  1043.       break;
  1044.     case R_WRITEQUANTIZATION:
  1045.       WriteDqt();
  1046.       break;
  1047.     case R_WRITERESYNC:
  1048.       WriteDri();
  1049.       break;
  1050.     case R_WRITEDNL:
  1051.       WriteDnl();
  1052.       break;
  1053.     case R_WRITEHUFFMAN:
  1054.       WriteDht();
  1055.       break;
  1056.     case R_ACCUSTOM:
  1057.       ntoken=yylex();
  1058.       ARRAYBEGIN;
  1059.       dest = yyint;
  1060.       InBounds(dest,0,MAXIMUM_DEVICES-1,"Bad device reference");
  1061.       if (ErrorValue) break;
  1062.       if (yylex()!=R_LBRACKET)
  1063.         {
  1064.           WHEREAMI();
  1065.           printf("Expected left bracket.\n");
  1066.           break;
  1067.         }
  1068.       MakeXhuff();
  1069.       MakeEhuff();
  1070.       if (!(ptr=(int *)calloc(257,sizeof(int))))
  1071.         {
  1072.           WHEREAMI();
  1073.           printf("Out of custom frequency space.\n");
  1074.           exit(ERROR_MEMORY);
  1075.         }
  1076.       for(i=0;i<257;i++)
  1077.         {
  1078.           ptr[i]=0;
  1079.         }
  1080.       while((ntoken=yylex())==R_INTEGER)
  1081.         {
  1082.           InBounds(yyint,0,MAXIMUM_SOURCES-1,"Bad frequency reference");
  1083.           if(ErrorValue) yyint=0;
  1084.           AddFrequency(ptr,CScan->ACFrequency[yyint]);
  1085.         }
  1086.       if (ntoken!=R_RBRACKET)
  1087.         {
  1088.           WHEREAMI();
  1089.           printf("Expected right bracket.\n");
  1090.           break;
  1091.         }
  1092.       MakeHuffman(ptr);
  1093.       SetACHuffman(dest);
  1094.       CImage->NumberACTables = 
  1095.         MAX(CImage->NumberACTables,(dest+1));
  1096.       ARRAYEND;
  1097.       break;
  1098.     case R_DCCUSTOM:
  1099.       ntoken=yylex();
  1100.       ARRAYBEGIN;
  1101.       dest = yyint;
  1102.       InBounds(dest,0,MAXIMUM_DEVICES-1,"Bad device reference");
  1103.       if (ErrorValue) break;
  1104.       if (yylex()!=R_LBRACKET)
  1105.         {
  1106.           WHEREAMI();
  1107.           printf("Expected left bracket.\n");
  1108.           break;
  1109.         }
  1110.       MakeXhuff();
  1111.       MakeEhuff();
  1112.       if (!(ptr=(int *)calloc(257,sizeof(int))))
  1113.         {
  1114.           WHEREAMI();
  1115.           printf("Out of custom frequency space.\n");
  1116.           exit(ERROR_MEMORY);
  1117.         }
  1118.       for(i=0;i<257;i++)
  1119.         {
  1120.           ptr[i]=0;
  1121.         }
  1122.       while((ntoken=yylex())==R_INTEGER)
  1123.         {
  1124.           InBounds(yyint,0,MAXIMUM_SOURCES-1,"Bad frequency reference");
  1125.           if(ErrorValue) yyint=0;
  1126.           AddFrequency(ptr,CScan->DCFrequency[yyint]);
  1127.         }
  1128.       if (ntoken!=R_RBRACKET)
  1129.         {
  1130.           WHEREAMI();
  1131.           printf("Expected right bracket.\n");
  1132.           break;
  1133.         }
  1134.       MakeHuffman(ptr);
  1135.       SetDCHuffman(dest);
  1136.       CImage->NumberDCTables = 
  1137.         MAX(CImage->NumberDCTables,(dest+1));
  1138.       ARRAYEND;
  1139.       break;
  1140.     case R_ACSPEC:
  1141.       ntoken=yylex();
  1142.       ARRAYBEGIN;
  1143.       dest = yyint;
  1144.       InBounds(dest,0,MAXIMUM_DEVICES-1,"Bad device reference");
  1145.       if (ErrorValue) break;
  1146.       MakeXhuff();
  1147.       MakeEhuff();
  1148.       if ((ntoken=yylex())==R_LBRACKET)
  1149.         {
  1150.           if (!(ptr=(int *)calloc(38,sizeof(int)))) /* Get bits */
  1151.         {
  1152.           WHEREAMI();
  1153.           printf("Out of custom bits space.\n");
  1154.           exit(ERROR_MEMORY);
  1155.         }
  1156.           for(i=0;i<32;i++)
  1157.         {
  1158.           ptr[i]=0;
  1159.         }
  1160.           for(accum=0,i=0;i<17;i++) /* First index is bitlength of 1. */
  1161.         {                 /* One additional to force r-bracket. */
  1162.           ntoken=yylex();
  1163.           if (ntoken==R_INTEGER)
  1164.             {
  1165.               accum+=yyint;
  1166.               ptr[i]=yyint;
  1167.             }
  1168.           else break;
  1169.         }
  1170.           if (ntoken!=R_RBRACKET)
  1171.         {
  1172.           WHEREAMI();
  1173.           printf("Expected integer or right bracket.\n");
  1174.           break;
  1175.         }
  1176.           if (yylex()!=R_LBRACKET)  /* Get values */
  1177.         {
  1178.           WHEREAMI();
  1179.           printf("Expected left bracket.\n");
  1180.           break;
  1181.         }
  1182.           if (!(ptr2=(int *)calloc(257,sizeof(int))))
  1183.         {
  1184.           WHEREAMI();
  1185.           printf("Out of custom Huffman value space.\n");
  1186.           exit(ERROR_MEMORY);
  1187.         }
  1188.           for(i=0;i<257;i++)
  1189.         {
  1190.           ptr2[i]=0;
  1191.         }
  1192.           for(i=0;i<257;i++) /* One additinal to force r-bracket */
  1193.         {
  1194.           ntoken=yylex();
  1195.           if (ntoken==R_INTEGER)
  1196.             {
  1197.               ptr2[i]=yyint;
  1198.             }
  1199.           else break;
  1200.         }
  1201.           if (i!=accum)
  1202.         {
  1203.           WHEREAMI();
  1204.           printf("Number of bitlengths != number of values.");
  1205.         }
  1206.           if (ntoken!=R_RBRACKET)
  1207.         {
  1208.           WHEREAMI();
  1209.           printf("Expected integer or right bracket.\n");
  1210.           break;
  1211.         }
  1212.           SpecifiedHuffman(ptr,ptr2);
  1213.         }
  1214.       else if (ntoken==R_CHROMINANCEDEFAULT)
  1215.         {
  1216.           SpecifiedHuffman(ChrominanceACBits,ChrominanceACValues);
  1217.         }
  1218.       else if (ntoken==R_LUMINANCEDEFAULT)
  1219.         {
  1220.           SpecifiedHuffman(LuminanceACBits,LuminanceACValues);
  1221.         }
  1222.       else
  1223.         {
  1224.           WHEREAMI();
  1225.           printf("Expected left bracket or ACDEFAULT.\n");
  1226.           break;
  1227.         }
  1228.       SetACHuffman(dest);
  1229.       CImage->NumberACTables = 
  1230.         MAX(CImage->NumberACTables,(dest+1));
  1231.       ARRAYEND;
  1232.       break;
  1233.     case R_DCSPEC:
  1234.       ntoken=yylex();
  1235.       ARRAYBEGIN;
  1236.       dest = yyint;
  1237.       InBounds(dest,0,MAXIMUM_DEVICES-1,"Bad device reference");
  1238.       if (ErrorValue) break;
  1239.       MakeXhuff();
  1240.       MakeEhuff();
  1241.       if ((ntoken=yylex())==R_LBRACKET)
  1242.         {
  1243.           if (!(ptr=(int *)calloc(38,sizeof(int)))) /* Get bits */
  1244.         {
  1245.           WHEREAMI();
  1246.           printf("Out of custom bits space.\n");
  1247.           exit(ERROR_MEMORY);
  1248.         }
  1249.           for(i=0;i<32;i++)
  1250.         {
  1251.           ptr[i]=0;
  1252.         }
  1253.           for(accum=0,i=0;i<17;i++) /* First index is bitlength of 1. */
  1254.         {                /* 0-16 to force right bracket. */
  1255.           ntoken=yylex();
  1256.           if (ntoken==R_INTEGER)
  1257.             {
  1258.               accum+=yyint;
  1259.               ptr[i]=yyint;
  1260.             }
  1261.           else break;
  1262.         }
  1263.           if (ntoken!=R_RBRACKET)
  1264.         {
  1265.           WHEREAMI();
  1266.           printf("Expected integer or right bracket.\n");
  1267.           break;
  1268.         }
  1269.           if (yylex()!=R_LBRACKET)  /* Get values */
  1270.         {
  1271.           WHEREAMI();
  1272.           printf("Expected left bracket.\n");
  1273.           break;
  1274.         }
  1275.           if (!(ptr2=(int *)calloc(257,sizeof(int))))
  1276.         {
  1277.           WHEREAMI();
  1278.           printf("Out of custom Huffman value space.\n");
  1279.           exit(ERROR_MEMORY);
  1280.         }
  1281.           for(i=0;i<257;i++)
  1282.         {
  1283.           ptr2[i]=0;
  1284.         }
  1285.           for(i=0;i<257;i++) /*One additional to force r-bracket.*/
  1286.         {
  1287.           ntoken=yylex();
  1288.           if (ntoken==R_INTEGER)
  1289.             {
  1290.               ptr2[i]=yyint;
  1291.             }
  1292.           else break;
  1293.         }
  1294.           if (i!=accum)
  1295.         {
  1296.           WHEREAMI();
  1297.           printf("Number of bitlengths != number of values.");
  1298.         }
  1299.           if (ntoken!=R_RBRACKET)
  1300.         {
  1301.           WHEREAMI();
  1302.           printf("Expected integer or right bracket.\n");
  1303.           break;
  1304.         }
  1305.           SpecifiedHuffman(ptr,ptr2);
  1306.         }
  1307.       else if (ntoken==R_CHROMINANCEDEFAULT)
  1308.         {
  1309.           SpecifiedHuffman(ChrominanceDCBits,ChrominanceDCValues);
  1310.         }
  1311.       else if (ntoken==R_LUMINANCEDEFAULT)
  1312.         {
  1313.           SpecifiedHuffman(LuminanceDCBits,LuminanceDCValues);
  1314.         }
  1315.       else
  1316.         {
  1317.           WHEREAMI();
  1318.           printf("Expected left bracket or DCDEFAULT.\n");
  1319.           break;
  1320.         }
  1321.       SetDCHuffman(dest);
  1322.       CImage->NumberDCTables = 
  1323.         MAX(CImage->NumberDCTables,(dest+1));
  1324.       ARRAYEND;
  1325.       break;
  1326.     }
  1327.     }
  1328. }
  1329.  
  1330. /*NOPROTO*/
  1331. /*END*/
  1332. int yyvstop[] ={
  1333. 0,
  1334.  
  1335. 16,
  1336. 0,
  1337.  
  1338. 1,
  1339. 16,
  1340. 0,
  1341.  
  1342. 1,
  1343. 0,
  1344.  
  1345. 16,
  1346. 0,
  1347.  
  1348. 12,
  1349. 16,
  1350. 0,
  1351.  
  1352. 16,
  1353. 0,
  1354.  
  1355. 12,
  1356. 16,
  1357. 0,
  1358.  
  1359. 12,
  1360. 16,
  1361. 0,
  1362.  
  1363. 4,
  1364. 16,
  1365. 0,
  1366.  
  1367. 4,
  1368. 16,
  1369. 0,
  1370.  
  1371. 4,
  1372. 16,
  1373. 0,
  1374.  
  1375. 12,
  1376. 16,
  1377. 0,
  1378.  
  1379. 12,
  1380. 16,
  1381. 0,
  1382.  
  1383. 12,
  1384. 16,
  1385. 0,
  1386.  
  1387. 2,
  1388. 16,
  1389. 0,
  1390.  
  1391. 2,
  1392. 16,
  1393. 0,
  1394.  
  1395. 10,
  1396. 12,
  1397. 16,
  1398. 0,
  1399.  
  1400. 11,
  1401. 12,
  1402. 16,
  1403. 0,
  1404.  
  1405. 17,
  1406. 0,
  1407.  
  1408. 17,
  1409. 0,
  1410.  
  1411. 17,
  1412. 0,
  1413.  
  1414. 13,
  1415. 0,
  1416.  
  1417. 12,
  1418. 0,
  1419.  
  1420. 3,
  1421. 0,
  1422.  
  1423. 14,
  1424. 0,
  1425.  
  1426. 3,
  1427. 0,
  1428.  
  1429. 4,
  1430. 0,
  1431.  
  1432. 4,
  1433. 0,
  1434.  
  1435. 8,
  1436. 0,
  1437.  
  1438. 6,
  1439. 0,
  1440.  
  1441. 8,
  1442. 0,
  1443.  
  1444. 8,
  1445. 0,
  1446.  
  1447. 2,
  1448. 0,
  1449.  
  1450. 2,
  1451. 0,
  1452.  
  1453. 2,
  1454. 6,
  1455. 0,
  1456.  
  1457. 15,
  1458. 0,
  1459.  
  1460. 13,
  1461. 0,
  1462.  
  1463. 9,
  1464. 0,
  1465.  
  1466. 3,
  1467. 0,
  1468.  
  1469. 3,
  1470. 0,
  1471.  
  1472. 7,
  1473. 0,
  1474.  
  1475. 5,
  1476. 0,
  1477.  
  1478. 3,
  1479. 0,
  1480.  
  1481. 3,
  1482. 0,
  1483.  
  1484. 3,
  1485. 0,
  1486.  
  1487. 3,
  1488. 0,
  1489. 0};
  1490. # define YYTYPE unsigned char
  1491. struct yywork { YYTYPE verify, advance; } yycrank[] ={
  1492. 0,0,    0,0,    3,7,    0,0,    
  1493. 0,0,    0,0,    0,0,    0,0,    
  1494. 0,0,    0,0,    3,8,    3,9,    
  1495. 0,0,    0,0,    8,9,    8,9,    
  1496. 0,0,    0,0,    0,0,    0,0,    
  1497. 0,0,    0,0,    0,0,    0,0,    
  1498. 0,0,    0,0,    0,0,    0,0,    
  1499. 0,0,    0,0,    0,0,    0,0,    
  1500. 0,0,    0,0,    0,0,    3,10,    
  1501. 3,11,    8,9,    0,0,    3,11,    
  1502. 3,12,    3,11,    3,11,    3,11,    
  1503. 3,11,    3,11,    30,50,    3,13,    
  1504. 3,14,    3,15,    3,16,    3,16,    
  1505. 3,16,    3,16,    3,16,    3,16,    
  1506. 3,16,    3,17,    14,35,    3,18,    
  1507. 3,11,    3,19,    3,11,    3,20,    
  1508. 6,26,    26,49,    3,21,    3,21,    
  1509. 31,51,    6,27,    18,33,    0,0,    
  1510. 3,22,    3,22,    19,33,    19,33,    
  1511. 0,0,    54,63,    0,0,    0,0,    
  1512. 3,22,    43,58,    43,58,    43,58,    
  1513. 43,58,    43,58,    43,58,    43,58,    
  1514. 43,58,    3,22,    0,0,    0,0,    
  1515. 3,23,    3,7,    3,24,    3,11,    
  1516. 4,11,    0,0,    0,0,    4,11,    
  1517. 4,12,    4,11,    4,11,    4,11,    
  1518. 0,0,    4,11,    0,0,    4,13,    
  1519. 4,14,    0,0,    4,16,    4,16,    
  1520. 4,16,    4,16,    4,16,    4,16,    
  1521. 4,16,    0,0,    0,0,    4,18,    
  1522. 4,11,    4,19,    4,11,    4,20,    
  1523. 3,11,    3,11,    3,11,    3,11,    
  1524. 5,25,    52,51,    0,0,    0,0,    
  1525. 0,0,    0,0,    0,0,    0,0,    
  1526. 5,25,    5,25,    52,60,    52,60,    
  1527. 52,60,    52,60,    52,60,    52,60,    
  1528. 52,60,    52,60,    0,0,    10,28,    
  1529. 0,0,    0,0,    0,0,    0,0,    
  1530. 4,23,    0,0,    4,24,    10,28,    
  1531. 10,28,    0,0,    12,31,    0,0,    
  1532. 0,0,    5,25,    0,0,    0,0,    
  1533. 0,0,    0,0,    12,31,    12,31,    
  1534. 0,0,    5,26,    5,25,    0,0,    
  1535. 0,0,    0,0,    5,27,    5,25,    
  1536. 0,0,    0,0,    0,0,    0,0,    
  1537. 10,29,    0,0,    0,0,    5,25,    
  1538. 4,11,    4,11,    4,11,    4,11,    
  1539. 0,0,    10,28,    0,0,    12,31,    
  1540. 5,25,    5,25,    10,28,    0,0,    
  1541. 0,0,    0,0,    5,25,    5,25,    
  1542. 12,31,    0,0,    10,28,    0,0,    
  1543. 0,0,    12,31,    5,25,    0,0,    
  1544. 0,0,    0,0,    0,0,    10,28,    
  1545. 10,28,    12,31,    0,0,    5,25,    
  1546. 0,0,    10,28,    10,28,    5,25,    
  1547. 0,0,    5,25,    12,31,    12,31,    
  1548. 0,0,    10,28,    0,0,    0,0,    
  1549. 12,31,    12,31,    0,0,    0,0,    
  1550. 0,0,    0,0,    10,28,    0,0,    
  1551. 12,31,    0,0,    10,30,    0,0,    
  1552. 10,28,    0,0,    0,0,    0,0,    
  1553. 0,0,    12,31,    0,0,    0,0,    
  1554. 0,0,    12,32,    13,33,    12,31,    
  1555. 13,34,    13,34,    13,34,    13,34,    
  1556. 13,34,    13,34,    13,34,    13,34,    
  1557. 13,34,    13,34,    15,36,    0,0,    
  1558. 15,37,    15,37,    15,37,    15,37,    
  1559. 15,37,    15,37,    15,37,    15,37,    
  1560. 15,38,    15,38,    0,0,    0,0,    
  1561. 0,0,    0,0,    0,0,    0,0,    
  1562. 0,0,    15,39,    15,40,    15,40,    
  1563. 15,39,    15,41,    15,39,    0,0,    
  1564. 15,42,    0,0,    0,0,    0,0,    
  1565. 0,0,    0,0,    0,0,    15,43,    
  1566. 60,31,    60,31,    60,31,    60,31,    
  1567. 60,31,    60,31,    60,31,    60,31,    
  1568. 15,44,    0,0,    0,0,    0,0,    
  1569. 0,0,    0,0,    0,0,    0,0,    
  1570. 0,0,    15,39,    15,40,    15,40,    
  1571. 15,39,    15,39,    15,39,    0,0,    
  1572. 15,42,    0,0,    0,0,    0,0,    
  1573. 0,0,    0,0,    0,0,    15,43,    
  1574. 0,0,    0,0,    0,0,    32,31,    
  1575. 0,0,    0,0,    0,0,    16,36,    
  1576. 15,44,    16,37,    16,37,    16,37,    
  1577. 16,37,    16,37,    16,37,    16,37,    
  1578. 16,37,    16,38,    16,38,    0,0,    
  1579. 0,0,    0,0,    0,0,    0,0,    
  1580. 0,0,    0,0,    16,39,    16,40,    
  1581. 16,40,    16,39,    16,41,    16,39,    
  1582. 0,0,    16,42,    0,0,    0,0,    
  1583. 0,0,    0,0,    0,0,    0,0,    
  1584. 16,45,    32,52,    32,52,    32,52,    
  1585. 32,52,    32,52,    32,52,    32,52,    
  1586. 32,52,    0,0,    0,0,    0,0,    
  1587. 0,0,    0,0,    0,0,    0,0,    
  1588. 0,0,    0,0,    16,39,    16,40,    
  1589. 16,40,    16,39,    16,39,    16,39,    
  1590. 0,0,    16,42,    0,0,    0,0,    
  1591. 0,0,    0,0,    0,0,    17,36,    
  1592. 16,45,    17,38,    17,38,    17,38,    
  1593. 17,38,    17,38,    17,38,    17,38,    
  1594. 17,38,    17,38,    17,38,    0,0,    
  1595. 0,0,    0,0,    0,0,    32,31,    
  1596. 0,0,    0,0,    17,39,    17,39,    
  1597. 17,39,    17,39,    17,41,    17,39,    
  1598. 0,0,    17,42,    34,34,    34,34,    
  1599. 34,34,    34,34,    34,34,    34,34,    
  1600. 34,34,    34,34,    34,34,    34,34,    
  1601. 56,66,    56,66,    56,66,    56,66,    
  1602. 56,66,    56,66,    56,66,    56,66,    
  1603. 56,66,    56,66,    0,0,    34,53,    
  1604. 0,0,    0,0,    17,39,    17,39,    
  1605. 17,39,    17,39,    17,39,    17,39,    
  1606. 0,0,    17,42,    21,46,    21,46,    
  1607. 21,46,    21,46,    21,46,    21,46,    
  1608. 21,46,    21,46,    21,46,    21,46,    
  1609. 0,0,    0,0,    0,0,    0,0,    
  1610. 0,0,    0,0,    0,0,    21,46,    
  1611. 21,46,    21,46,    21,46,    21,46,    
  1612. 21,46,    21,47,    21,48,    21,47,    
  1613. 21,47,    21,47,    21,47,    21,47,    
  1614. 21,47,    21,47,    21,47,    21,47,    
  1615. 21,47,    21,47,    21,47,    21,47,    
  1616. 21,47,    21,47,    21,47,    21,47,    
  1617. 21,47,    0,0,    0,0,    0,0,    
  1618. 0,0,    0,0,    0,0,    21,46,    
  1619. 21,46,    21,46,    21,46,    21,46,    
  1620. 21,46,    21,47,    21,48,    21,47,    
  1621. 21,47,    21,47,    21,47,    21,47,    
  1622. 21,47,    21,47,    21,47,    21,47,    
  1623. 21,47,    21,47,    21,47,    21,47,    
  1624. 21,47,    21,47,    21,47,    21,47,    
  1625. 21,47,    22,47,    22,47,    22,47,    
  1626. 22,47,    22,47,    22,47,    22,47,    
  1627. 22,47,    22,47,    22,47,    0,0,    
  1628. 0,0,    0,0,    0,0,    0,0,    
  1629. 0,0,    0,0,    22,47,    22,47,    
  1630. 22,47,    22,47,    22,47,    22,47,    
  1631. 0,0,    22,47,    36,54,    36,54,    
  1632. 36,54,    36,54,    36,54,    36,54,    
  1633. 36,54,    36,54,    36,54,    36,54,    
  1634. 57,57,    57,57,    57,57,    57,57,    
  1635. 57,57,    57,57,    57,57,    57,57,    
  1636. 57,57,    57,57,    0,0,    36,55,    
  1637. 0,0,    0,0,    22,47,    22,47,    
  1638. 22,47,    22,47,    22,47,    22,47,    
  1639. 0,0,    22,47,    39,39,    39,39,    
  1640. 39,39,    39,39,    39,39,    39,39,    
  1641. 39,39,    39,39,    39,39,    39,39,    
  1642. 0,0,    0,0,    0,0,    0,0,    
  1643. 0,0,    0,0,    0,0,    39,39,    
  1644. 39,39,    39,39,    39,39,    39,39,    
  1645. 39,39,    41,56,    39,42,    41,56,    
  1646. 0,0,    0,0,    41,57,    41,57,    
  1647. 41,57,    41,57,    41,57,    41,57,    
  1648. 41,57,    41,57,    41,57,    41,57,    
  1649. 61,62,    61,62,    61,62,    61,62,    
  1650. 61,62,    61,62,    61,62,    61,62,    
  1651. 61,62,    61,62,    0,0,    39,39,    
  1652. 39,39,    39,39,    39,39,    39,39,    
  1653. 39,39,    0,0,    39,42,    44,59,    
  1654. 44,59,    44,59,    44,59,    44,59,    
  1655. 44,59,    44,59,    44,59,    44,59,    
  1656. 44,59,    0,0,    0,0,    0,0,    
  1657. 0,0,    0,0,    0,0,    0,0,    
  1658. 44,59,    44,59,    44,59,    44,59,    
  1659. 44,59,    44,59,    47,47,    47,47,    
  1660. 47,47,    47,47,    47,47,    47,47,    
  1661. 47,47,    47,47,    47,47,    47,47,    
  1662. 0,0,    0,0,    0,0,    0,0,    
  1663. 0,0,    0,0,    0,0,    47,47,    
  1664. 47,47,    47,47,    47,47,    47,47,    
  1665. 47,47,    0,0,    47,47,    0,0,    
  1666. 44,59,    44,59,    44,59,    44,59,    
  1667. 44,59,    44,59,    53,61,    0,0,    
  1668. 53,61,    0,0,    0,0,    53,62,    
  1669. 53,62,    53,62,    53,62,    53,62,    
  1670. 53,62,    53,62,    53,62,    53,62,    
  1671. 53,62,    0,0,    0,0,    47,47,    
  1672. 47,47,    47,47,    47,47,    47,47,    
  1673. 47,47,    0,0,    47,47,    48,47,    
  1674. 48,47,    48,47,    48,47,    48,47,    
  1675. 48,47,    48,47,    48,47,    48,47,    
  1676. 48,47,    0,0,    0,0,    0,0,    
  1677. 0,0,    0,0,    0,0,    0,0,    
  1678. 48,47,    48,47,    48,47,    48,47,    
  1679. 48,47,    48,47,    55,64,    48,47,    
  1680. 55,64,    0,0,    0,0,    55,65,    
  1681. 55,65,    55,65,    55,65,    55,65,    
  1682. 55,65,    55,65,    55,65,    55,65,    
  1683. 55,65,    64,65,    64,65,    64,65,    
  1684. 64,65,    64,65,    64,65,    64,65,    
  1685. 64,65,    64,65,    64,65,    0,0,    
  1686. 48,47,    48,47,    48,47,    48,47,    
  1687. 48,47,    48,47,    63,67,    48,47,    
  1688. 63,67,    0,0,    0,0,    63,68,    
  1689. 63,68,    63,68,    63,68,    63,68,    
  1690. 63,68,    63,68,    63,68,    63,68,    
  1691. 63,68,    67,68,    67,68,    67,68,    
  1692. 67,68,    67,68,    67,68,    67,68,    
  1693. 67,68,    67,68,    67,68,    0,0,    
  1694. 0,0};
  1695. struct yysvf yysvec[] ={
  1696. 0,    0,    0,
  1697. yycrank+0,    0,        0,    
  1698. yycrank+0,    0,        0,    
  1699. yycrank+-1,    0,        0,    
  1700. yycrank+-61,    yysvec+3,    0,    
  1701. yycrank+-127,    0,        0,    
  1702. yycrank+-22,    yysvec+5,    0,    
  1703. yycrank+0,    0,        yyvstop+1,
  1704. yycrank+5,    0,        yyvstop+3,
  1705. yycrank+0,    yysvec+8,    yyvstop+6,
  1706. yycrank+-146,    0,        yyvstop+8,
  1707. yycrank+0,    0,        yyvstop+10,
  1708. yycrank+-157,    0,        yyvstop+13,
  1709. yycrank+204,    0,        yyvstop+15,
  1710. yycrank+16,    0,        yyvstop+18,
  1711. yycrank+216,    0,        yyvstop+21,
  1712. yycrank+289,    0,        yyvstop+24,
  1713. yycrank+353,    0,        yyvstop+27,
  1714. yycrank+9,    0,        yyvstop+30,
  1715. yycrank+13,    0,        yyvstop+33,
  1716. yycrank+0,    yysvec+18,    yyvstop+36,
  1717. yycrank+410,    0,        yyvstop+39,
  1718. yycrank+485,    yysvec+21,    yyvstop+42,
  1719. yycrank+0,    0,        yyvstop+45,
  1720. yycrank+0,    0,        yyvstop+49,
  1721. yycrank+0,    0,        yyvstop+53,
  1722. yycrank+18,    0,        yyvstop+55,
  1723. yycrank+0,    yysvec+14,    yyvstop+57,
  1724. yycrank+0,    yysvec+10,    0,    
  1725. yycrank+0,    0,        yyvstop+59,
  1726. yycrank+-12,    yysvec+10,    0,    
  1727. yycrank+29,    0,        0,    
  1728. yycrank+321,    0,        0,    
  1729. yycrank+0,    0,        yyvstop+61,
  1730. yycrank+378,    0,        yyvstop+63,
  1731. yycrank+0,    0,        yyvstop+65,
  1732. yycrank+510,    0,        yyvstop+67,
  1733. yycrank+0,    yysvec+16,    yyvstop+69,
  1734. yycrank+0,    yysvec+17,    yyvstop+71,
  1735. yycrank+542,    0,        0,    
  1736. yycrank+0,    yysvec+39,    yyvstop+73,
  1737. yycrank+570,    yysvec+39,    0,    
  1738. yycrank+0,    0,        yyvstop+75,
  1739. yycrank+33,    0,        yyvstop+77,
  1740. yycrank+599,    0,        0,    
  1741. yycrank+0,    0,        yyvstop+79,
  1742. yycrank+0,    yysvec+21,    yyvstop+81,
  1743. yycrank+622,    yysvec+21,    yyvstop+83,
  1744. yycrank+679,    yysvec+21,    yyvstop+85,
  1745. yycrank+0,    0,        yyvstop+88,
  1746. yycrank+0,    yysvec+10,    yyvstop+90,
  1747. yycrank+0,    0,        yyvstop+92,
  1748. yycrank+90,    0,        0,    
  1749. yycrank+659,    0,        0,    
  1750. yycrank+8,    yysvec+36,    yyvstop+94,
  1751. yycrank+707,    0,        0,    
  1752. yycrank+388,    0,        0,    
  1753. yycrank+520,    yysvec+39,    yyvstop+96,
  1754. yycrank+0,    yysvec+43,    yyvstop+98,
  1755. yycrank+0,    yysvec+44,    yyvstop+100,
  1756. yycrank+248,    yysvec+52,    0,    
  1757. yycrank+580,    0,        0,    
  1758. yycrank+0,    yysvec+61,    yyvstop+102,
  1759. yycrank+739,    0,        0,    
  1760. yycrank+717,    0,        0,    
  1761. yycrank+0,    yysvec+64,    yyvstop+104,
  1762. yycrank+0,    yysvec+56,    yyvstop+106,
  1763. yycrank+749,    0,        0,    
  1764. yycrank+0,    yysvec+67,    yyvstop+108,
  1765. 0,    0,    0};
  1766. struct yywork *yytop = yycrank+806;
  1767. struct yysvf *yybgin = yysvec+1;
  1768. char yymatch[] ={
  1769. 00  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  1770. 01  ,011 ,012 ,01  ,01  ,01  ,01  ,01  ,
  1771. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  1772. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  1773. 011 ,01  ,'"' ,01  ,01  ,01  ,01  ,01  ,
  1774. 01  ,01  ,01  ,'+' ,01  ,'+' ,01  ,01  ,
  1775. '0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,
  1776. '8' ,'8' ,01  ,01  ,01  ,01  ,01  ,01  ,
  1777. 01  ,'A' ,'B' ,'B' ,'A' ,'A' ,'A' ,'G' ,
  1778. 'H' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'O' ,
  1779. 'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,
  1780. 'X' ,'G' ,'G' ,01  ,0134,01  ,'^' ,01  ,
  1781. 01  ,'A' ,'B' ,'B' ,'A' ,'A' ,'A' ,'G' ,
  1782. 'H' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'O' ,
  1783. 'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,
  1784. 'X' ,'G' ,'G' ,01  ,01  ,01  ,01  ,01  ,
  1785. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  1786. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  1787. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  1788. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  1789. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  1790. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  1791. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  1792. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  1793. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  1794. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  1795. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  1796. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  1797. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  1798. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  1799. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  1800. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  1801. 0};
  1802. char yyextra[] ={
  1803. 0,0,0,0,0,0,0,0,
  1804. 0,0,0,0,0,0,0,0,
  1805. 0,0,0,0,0,0,0,0,
  1806. 0};
  1807. /*    ncform    4.1    83/08/11    */
  1808.  
  1809. int yylineno =1;
  1810. # define YYU(x) x
  1811. # define NLSTATE yyprevious=YYNEWLINE
  1812. char yytext[YYLMAX];
  1813. struct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp;
  1814. char yysbuf[YYLMAX];
  1815. char *yysptr = yysbuf;
  1816. int *yyfnd;
  1817. extern struct yysvf *yyestate;
  1818. int yyprevious = YYNEWLINE;
  1819. yylook(){
  1820.     register struct yysvf *yystate, **lsp;
  1821.     register struct yywork *yyt;
  1822.     struct yysvf *yyz;
  1823.     int yych;
  1824.     struct yywork *yyr;
  1825. # ifdef LEXDEBUG
  1826.     int debug;
  1827. # endif
  1828.     char *yylastch;
  1829.     /* start off machines */
  1830. # ifdef LEXDEBUG
  1831.     debug = 0;
  1832. # endif
  1833.     if (!yymorfg)
  1834.         yylastch = yytext;
  1835.     else {
  1836.         yymorfg=0;
  1837.         yylastch = yytext+yyleng;
  1838.         }
  1839.     for(;;){
  1840.         lsp = yylstate;
  1841.         yyestate = yystate = yybgin;
  1842.         if (yyprevious==YYNEWLINE) yystate++;
  1843.         for (;;){
  1844. # ifdef LEXDEBUG
  1845.             if(debug)fprintf(yyout,"state %d\n",yystate-yysvec-1);
  1846. # endif
  1847.             yyt = yystate->yystoff;
  1848.             if(yyt == yycrank){        /* may not be any transitions */
  1849.                 yyz = yystate->yyother;
  1850.                 if(yyz == 0)break;
  1851.                 if(yyz->yystoff == yycrank)break;
  1852.                 }
  1853.             *yylastch++ = yych = input();
  1854.         tryagain:
  1855. # ifdef LEXDEBUG
  1856.             if(debug){
  1857.                 fprintf(yyout,"unsigned char ");
  1858.                 allprint(yych);
  1859.                 putchar('\n');
  1860.                 }
  1861. # endif
  1862.             yyr = yyt;
  1863.             if ( (int)yyt > (int)yycrank){
  1864.                 yyt = yyr + yych;
  1865.                 if (yyt <= yytop && yyt->verify+yysvec == yystate){
  1866.                     if(yyt->advance+yysvec == YYLERR)    /* error transitions */
  1867.                         {unput(*--yylastch);break;}
  1868.                     *lsp++ = yystate = yyt->advance+yysvec;
  1869.                     goto contin;
  1870.                     }
  1871.                 }
  1872. # ifdef YYOPTIM
  1873.             else if((int)yyt < (int)yycrank) {        /* r < yycrank */
  1874.                 yyt = yyr = yycrank+(yycrank-yyt);
  1875. # ifdef LEXDEBUG
  1876.                 if(debug)fprintf(yyout,"compressed state\n");
  1877. # endif
  1878.                 yyt = yyt + yych;
  1879.                 if(yyt <= yytop && yyt->verify+yysvec == yystate){
  1880.                     if(yyt->advance+yysvec == YYLERR)    /* error transitions */
  1881.                         {unput(*--yylastch);break;}
  1882.                     *lsp++ = yystate = yyt->advance+yysvec;
  1883.                     goto contin;
  1884.                     }
  1885.                 yyt = yyr + YYU(yymatch[yych]);
  1886. # ifdef LEXDEBUG
  1887.                 if(debug){
  1888.                     fprintf(yyout,"try fall back character ");
  1889.                     allprint(YYU(yymatch[yych]));
  1890.                     putchar('\n');
  1891.                     }
  1892. # endif
  1893.                 if(yyt <= yytop && yyt->verify+yysvec == yystate){
  1894.                     if(yyt->advance+yysvec == YYLERR)    /* error transition */
  1895.                         {unput(*--yylastch);break;}
  1896.                     *lsp++ = yystate = yyt->advance+yysvec;
  1897.                     goto contin;
  1898.                     }
  1899.                 }
  1900.             if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank){
  1901. # ifdef LEXDEBUG
  1902.                 if(debug)fprintf(yyout,"fall back to state %d\n",yystate-yysvec-1);
  1903. # endif
  1904.                 goto tryagain;
  1905.                 }
  1906. # endif
  1907.             else
  1908.                 {unput(*--yylastch);break;}
  1909.         contin:
  1910. # ifdef LEXDEBUG
  1911.             if(debug){
  1912.                 fprintf(yyout,"state %d char ",yystate-yysvec-1);
  1913.                 allprint(yych);
  1914.                 putchar('\n');
  1915.                 }
  1916. # endif
  1917.             ;
  1918.             }
  1919. # ifdef LEXDEBUG
  1920.         if(debug){
  1921.             fprintf(yyout,"stopped at %d with ",*(lsp-1)-yysvec-1);
  1922.             allprint(yych);
  1923.             putchar('\n');
  1924.             }
  1925. # endif
  1926.         while (lsp-- > yylstate){
  1927.             *yylastch-- = 0;
  1928.             if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0){
  1929.                 yyolsp = lsp;
  1930.                 if(yyextra[*yyfnd]){        /* must backup */
  1931.                     while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate){
  1932.                         lsp--;
  1933.                         unput(*yylastch--);
  1934.                         }
  1935.                     }
  1936.                 yyprevious = YYU(*yylastch);
  1937.                 yylsp = lsp;
  1938.                 yyleng = yylastch-yytext+1;
  1939.                 yytext[yyleng] = 0;
  1940. # ifdef LEXDEBUG
  1941.                 if(debug){
  1942.                     fprintf(yyout,"\nmatch ");
  1943.                     sprint(yytext);
  1944.                     fprintf(yyout," action %d\n",*yyfnd);
  1945.                     }
  1946. # endif
  1947.                 return(*yyfnd++);
  1948.                 }
  1949.             unput(*yylastch);
  1950.             }
  1951.         if (yytext[0] == 0  /* && feof(yyin) */)
  1952.             {
  1953.             yysptr=yysbuf;
  1954.             return(0);
  1955.             }
  1956.         yyprevious = yytext[0] = input();
  1957.         if (yyprevious>0)
  1958.             output(yyprevious);
  1959.         yylastch=yytext;
  1960. # ifdef LEXDEBUG
  1961.         if(debug)putchar('\n');
  1962. # endif
  1963.         }
  1964.     }
  1965. yyback(p, m)
  1966.     int *p;
  1967. {
  1968. if (p==0) return(0);
  1969. while (*p)
  1970.     {
  1971.     if (*p++ == m)
  1972.         return(1);
  1973.     }
  1974. return(0);
  1975. }
  1976.     /* the following are only used in the lex library */
  1977. yyinput(){
  1978.     return(input());
  1979.     }
  1980. yyoutput(c)
  1981.   int c; {
  1982.     output(c);
  1983.     }
  1984. yyunput(c)
  1985.    int c; {
  1986.     unput(c);
  1987.     }
  1988.